<% current_item = "" %>
<% if @user.nil? %>
<h1>Login</h1>
<%= form_tag :action => "login", :style => "padding:0;margin:0" %>
<p>
<% @focus_control = "LoginName" %>
<% @loginname ||= '' %>
User Name: <%= text_field_tag 'LoginName', @loginname, :size => 12 %><br>
Password: <%= password_field_tag 'Password', "", :size => 12 %><br>
<%= submit_tag "Login" %>
</p>
<%= end_form_tag %>
<% end %>
<% control = Control.find_by_ControlKey("BannerItems") %>
<% if control %>
<h1>My News</h1>
<p>
<% 
control.Memo.each("\t") { |line| 
    if(current_item == "")
        current_item = line
    else %>
        <%= link_to current_item.chomp.strip, line.chomp.strip %><br/>
<%      current_item = ""; end  }%>
</p>
<% end %>
<h1>Shelby News</h1>
<p>
<%
    begin
    file_path = File.join(RAILS_ROOT, "files/ShelbyInfo/", Date.today.to_s + ".zip")
    if(!File.exists?(file_path))
        req,body = Net::HTTP::get_response('www.shelbyinc.com','/feeds/shelbyinfo/ShelbyINFO.zip')
        f = File.new(file_path, "wb")
        f.write body
        f.close
    end
    Zip::ZipInputStream::open(file_path) { |io|
        while (entry = io.get_next_entry)
            if(entry.name == "ShelbyRSS.txt")
                @shelby_rss = io.read
            end
        end
    }
    @shelby_rss.gsub!(/<IMG [0-9]*>/, '')
    current_item = ""
    @shelby_rss.each_line { |line| 
    if(current_item == "")
        current_item = line
    else %>
        <%= link_to current_item.chomp, line.chomp %><br/>
<% 
        current_item = ""
    end
    } 
    
    rescue
    end%>
</p>
    